<script>
	import Vue from 'vue'
	
	export default {
		onLaunch: function() {
	let myInfo = uni.getStorageSync("userInfo")
	const data = JSON.stringify({
				code: "1001",
				id: myInfo.id,
				type: 0, // 0表示私聊，1表示群聊
			})
	// 打开一个websocket
	 var websocket = uni.connectSocket({
		url: 'ws://127.0.0.1:8085',
		success: () => {
			console.log("websocket连接成功")
		}
	})
	// 建立连接
	websocket.onOpen(evt => {
		console.log("websocket连接已打开")
		// 发送我已上线的消息
		websocket.send({
			data: data
		})
	})
			// websocket.onMessage(()=>{
			// 	if(this.$route.path != "/pages/contact/index"){
			// 		uni.showTabBarRedDot({ //显示红点
			// 		  index: 2,
			// 		  text: '1'
			// 		})
			// 	}
			// })
			Vue.prototype.websocket = websocket
			

			uni.getSystemInfo({
				success: function(e) {
					// #ifndef MP
					Vue.prototype.StatusBar = e.statusBarHeight
					if (e.platform == 'android') {
						Vue.prototype.CustomBar = e.statusBarHeight + 50
					} else {
						Vue.prototype.CustomBar = e.statusBarHeight + 45
					}
					// #endif
			
					// #ifdef MP-WEIXIN
					Vue.prototype.StatusBar = e.statusBarHeight
					let custom = wx.getMenuButtonBoundingClientRect()
					Vue.prototype.Custom = custom
					Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight
					// #endif		
			
					// #ifdef MP-ALIPAY
					Vue.prototype.StatusBar = e.statusBarHeight
					Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight
					// #endif
				}
			})
		},
	};
</script>
<style lang="scss">
	@import "uview-ui/index.scss";
	@import "uview-ui/theme.scss";
	.all {
		position: relative;
		min-height: 100vh;
		height: auto;
		box-sizing: border-box;
		color: $u-content-color;
		font-size: 32rpx;
		background-color:#e0fafb ;
	}
	.u-nav-slot {
		@include flex;
		.nav-title {
			padding-left: 10rpx;
		}
	}
	.u-nav-slot-right {
		margin-right: 90px;
	}
</style>